package cn.tedu.start.controller.petcontroller;
import cn.tedu.commons.response.JsonPage;
import cn.tedu.commons.response.JsonResult;
import cn.tedu.pojo.pet.dto.PetTypeDTO;
import cn.tedu.pojo.pet.vo.PetTypeVO;
import cn.tedu.service.petcommodity.IPetTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "1,宠物类别模块")
@RestController
@RequestMapping("/type")
public class PetTypeController {
    @Autowired(required = false)
    private IPetTypeService petTypeService;

    @ApiOperation("在页面返回所有id的宠物类型")
    @GetMapping("/list")
    public JsonResult<List<PetTypeVO>> getPetTypeName(){
        return JsonResult.ok(petTypeService.getPetTypeName());
    }

    //TODO
    @ApiOperation("管理员添加宠物类型")
    @PostMapping("/add")
    public JsonResult addType(@RequestBody PetTypeDTO petTypeDTO){
        petTypeService.addType(petTypeDTO);
        return JsonResult.ok("添加宠物类型成功");
    }

    @ApiOperation("管理员修改宠物类别")
    @GetMapping("/update/typename")
    public JsonResult updatePetType(String typeName,String newName){
        petTypeService.updatePetType(typeName,newName);
        return JsonResult.ok("修改宠物类型成功");
    }

    @ApiOperation("管理员修改类别是否启用该")
    @GetMapping("/update/delete")
    public JsonResult updateIsDelete(String typeName,Integer isDelete){
        petTypeService.updateIsDelete(typeName,isDelete);
        return JsonResult.ok("修改宠物是否启用成功");
    }



}
